package cc.cc4414.cc03.core.swagger;

import java.util.Arrays;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * Swagger2的配置
 * 
 * @author cc 2018年7月5日
 */
@EnableSwagger2
@Configuration
public class SwaggerConfig {
	@Bean
	public Docket api() {
		// 配置请求头参数可以传token
		Parameter parameter = new ParameterBuilder().name("Authorization").description("令牌")
				.modelRef(new ModelRef("string")).parameterType("header").required(false).build();
		return new Docket(DocumentationType.SWAGGER_2).globalOperationParameters(Arrays.asList(parameter));
	}
}
